@extends('layouts.admin')
@section('css')
    <link href="{{asset('vendors/iCheck/custom.css')}}" rel="stylesheet">
@endsection
@section('content')
    @inject('userPresenter','App\Presenters\Admin\UserPresenter')
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-lg-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>{!!trans('admin/user.info')!!}</h5>
                        <div class="ibox-tools">
                            <button id="update-wechat-btn" data-toggle="modal" data-target="#update-wechat-qrcode-modal"
                                    class="btn btn-info"><i class="fa fa-wechat"></i> 更新微信信息
                            </button>
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <form class="form-horizontal">
                            <div class="form-group">
                                <label class="col-sm-2 control-label">{{trans('admin/user.model.name')}}</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">{{$user->name}}</p>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group{{ $errors->has('username') ? ' has-error' : '' }}">
                                <label class="col-sm-2 control-label">{{trans('admin/user.model.username')}}</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">{{$user->username}}</p>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
                                <label class="col-sm-2 control-label">{{trans('admin/user.model.email')}}</label>
                                <div class="col-sm-10">
                                    <p class="form-control-static">{{$user->email}}</p>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">{{trans('admin/user.role')}}</label>
                                <div class="col-sm-10">
                                    {!!$userPresenter->showUserRoles($user->roles)!!}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <label class="col-sm-2 control-label">{{trans('admin/user.permission')}}</label>
                                <div class="col-sm-10">
                                    <div class="ibox float-e-margins">
                                        <table class="table table-bordered">
                                            <thead>
                                            <tr>
                                                <th class="col-md-1 text-center">{{trans('admin/user.module')}}</th>
                                                <th class="col-md-10 text-center">{{trans('admin/user.permission')}}</th>
                                            </tr>
                                            </thead>
                                            <tbody>
                                            {!! $userPresenter->showUserPermissions($user->userPermissions) !!}
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>
                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-2">
                                    <a class="btn btn-white"
                                       href="{{url()->previous()}}">{!!trans('admin/action.actionButton.cancel')!!}</a>
                                    <a class="btn btn-primary" href="{{url('/user/edit')}}"><i
                                                class="fa fa-pencil-square-o"></i> {!!trans('admin/action.actionButton.edit')!!}
                                    </a>

                                </div>
                            </div>
                        </form>
                        <!-- QRCode Modal -->
                        <div class="modal fade qrcode-modal" id="update-wechat-qrcode-modal" tabindex="-1" role="dialog"
                             aria-labelledby="update-wechat-qrcode-modal">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <button type="button" class="close" data-dismiss="modal"
                                                aria-label="Close"><span
                                                    aria-hidden="true">&times;</span></button>
                                        <h4 class="modal-title">扫码更新。您的专属二维码，请勿泄露。</h4>
                                    </div>
                                    <div class="modal-body" style="text-align: center">
                                        <div><img class="qrcode-img" src="{{$wechat['qrcode']}}" alt=""></div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    @include('admin.user.modal')
@endsection
@section('js')
    <script type="text/javascript" src="{{asset('vendors/iCheck/icheck.min.js')}}"></script>
    <script type="text/javascript" src="{{asset('admin/js/user/user.js')}}"></script>
@endsection